package com.ruoyi.project.system.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.system.domain.SysGoodsImg;
import com.ruoyi.project.system.service.ISysGoodsImgService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * Controller
 * 
 * @author jjp
 * @date 2020-04-21
 */
@RestController
@RequestMapping("/system/img")
public class SysGoodsImgController extends BaseController
{
    @Autowired
    private ISysGoodsImgService sysGoodsImgService;

    /**
     * 查询评论图片列表
     */
    @PreAuthorize("@ss.hasPermi('system:img:list')")
    @GetMapping("/list")
    public TableDataInfo list(SysGoodsImg sysGoodsImg)
    {
        startPage();
        List<SysGoodsImg> list = sysGoodsImgService.selectSysGoodsImgList(sysGoodsImg);
        return getDataTable(list);
    }

    /**
     * 获取评论图片详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:img:query')")
    @GetMapping(value = "/{imgId}")
    public AjaxResult getInfo(@PathVariable("imgId") Long imgId)
    {
        return AjaxResult.success(sysGoodsImgService.selectSysGoodsImgById(imgId));
    }

    /**
     * 新增评论图片
     */
    @PreAuthorize("@ss.hasPermi('system:img:add')")
    @Log(title = "新增评论图片", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SysGoodsImg sysGoodsImg)
    {
        return toAjax(sysGoodsImgService.insertSysGoodsImg(sysGoodsImg));
    }

    /**
     * 修改评论图片
     */
    @PreAuthorize("@ss.hasPermi('system:img:edit')")
    @Log(title = "修改评论图片", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SysGoodsImg sysGoodsImg)
    {
        return toAjax(sysGoodsImgService.updateSysGoodsImg(sysGoodsImg));
    }

    /**
     * 删除评论图片
     */
    @PreAuthorize("@ss.hasPermi('system:img:remove')")
    @Log(title = "删除评论图片", businessType = BusinessType.DELETE)
	@DeleteMapping("/{imgIds}")
    public AjaxResult remove(@PathVariable Long[] imgIds)
    {
        return toAjax(sysGoodsImgService.deleteSysGoodsImgByIds(imgIds));
    }
}
